package com.github.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author fatfish
 * @version 1.0
 * @date 2025/8/21 14:57
 */
@Controller
@RequestMapping("/helloController") // 类级别的请求路径
public class HelloController {

    // 方法级别的请求路径
    // 真实访问地址: /your_project/helloController/hello
    @RequestMapping("/hello")
    public String sayHello(Model model) {
        // 向模型中添加属性 msg，可以在 JSP 中获取
        model.addAttribute("msg", "Hello, SpringMVC! (Annotation Version)");
        // 返回视图名
        // WEB-INF/jsp/hello.jsp
        return "hello";
    }
}
